package org.mine.design.bridge.controller;

import lombok.extern.slf4j.Slf4j;
import org.mine.design.bridge.service.PayFeeService;
import org.mine.design.bridge.service.PayFreeAbstract;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class BridgeController {

    @Autowired
    private PayFreeAbstract payFreeAbstract;

    @Autowired
    private List<PayFeeService> payFeeServices;


    /**
     * 计算商家在个平台销售商品所要缴纳的费用
     * 已知：当前全部平台如果是公益商品的话，则免去商品费
     */
    @RequestMapping("/bridge/test")
    public void test() {
        Boolean publicGood = false;
        int commodityPrices = 19;
        payFeeServices.forEach(service -> {
            int payment = payFreeAbstract.payFree(service, publicGood, commodityPrices);
            String platformName = service.platformName();
            log.info("平台名称 = {} , 需要缴纳的商品销售费用 = {}", platformName, payment);
        });

    }
}
